using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Media;
using System.Xml.Serialization;
using WozLib.Xml;
using WozLib.UI.Ink.SketchObjects;

namespace WozLib.UI.Ink.SketchProperties
{
  public class ColorSketchProperty : SketchProperty
  {

    [XmlIgnore]
    public Color Data
    {
      get { return _Data; }
      set
      {
        if (value != _Data)
        {
          _Data = value;

          FirePropertyChanged("Data");
          NotifyPropertyChanged();
        }
      }

    } private Color _Data;

    [XmlElement("ColorXmlSerializable")]
    public ColorXmlSerializable ColorXmlSerializable
    {
      get { return new ColorXmlSerializable(Data); }
      set { Data = value.Color; }
    }
    
    public ColorSketchProperty(Color data, WozPropertyType wozPropertyType)
      : base(wozPropertyType)
    {
      Data = data;
    }

    public ColorSketchProperty(WozPropertyType wozPropertyType)
      : base(wozPropertyType)
    {
    }

    public ColorSketchProperty()
      : base()
    {
    }

    // Color is not cloneable
    // maybe we need to make a new one?
    public override object Clone()
    {
      return new ColorSketchProperty(Data,this.WozPropertyType);
    }

    /// <summary>
    /// Returns true if .equals on the color Data is true
    /// </summary>
    /// <param name="obj"></param>
    /// <returns></returns>
    public override bool Equals(object obj)
    {
      if (obj is ColorSketchProperty && (obj as ColorSketchProperty).Data == Data)
      {
        return true;
      }
      else
      {
        return false;
      }
    }

    public override CascadingProperty CreateCascadingProperty(List<ISketchObject> iWozObjects)
    {
      return new ColorCascadingProperty(iWozObjects, this);
    }
  }
}
